#ifndef QTSNAKE_H
#define QTSNAKE_H

#include <QMainWindow>
#include<qpainter.h>
#include <QTimer>
#include <QTextBlock>
#include<QVector>
#include<qstring.h>
namespace Ui {
class QtSnake;
}

class QtSnake : public QMainWindow
{
    Q_OBJECT

public:
    explicit QtSnake(QWidget *parent = 0);
    ~QtSnake();
    void paintEvent(QPaintEvent *event);
    void initSnake();//初始化蛇
    QRect CreateFood();
    void IfEat();
    void IfHit();
    void IfWin();

private slots:
    void placeUpdate();//定义槽函数

private:
    Ui::QtSnake *ui;
    QVector<QRect> vSnakeRect1,vSnakeRect2;//蛇
    QRect SnakeHead1,SnakeHead2;//蛇头
    void keyPressEvent(QKeyEvent *key);//定义键盘事件
    QTimer *timer;//定时器
    bool blsRun;//是否开始
    bool blsOver;//是否结束
    QString ifDisplay,rule1,rule2,rule3,rule4,rule5,rule6;//开始和结束提示
    int newDirection1,newDirection2;//蛇的移动方向
    QRect food;//食物
    int Score1,Score2,timerspeed=500;//统计得分
    QString scoreLabel1,scoreLabel2;//显示得分二字
};

#endif // QTSNAKE_H
